package com.chuantou.yuba.util;

import android.content.Context;
import android.os.AsyncTask;

import com.chuantou.yuba.dao.CacheDao;
import com.chuantou.yuba.pojo.Cache;
import com.chuantou.yuba.pojo.Cacheable;

/**
 * 从缓存中读取数据的异步任务
 * 
 * @author dl1001
 * 
 * @param <T>
 */
public class LoadCacheTask<T extends Cacheable> extends AsyncTask<Void, Void, Cache<T>> {
	private Class<T> mClazz;
	private String mCacheKey;
	private Context mContext;

	public LoadCacheTask(Context context, String cacheKey, Class<T> clazz) {
		this.mClazz = clazz;
		this.mCacheKey = cacheKey;
		this.mContext = context;
	}

	@Override
	protected Cache<T> doInBackground(Void... params) {
		return CacheDao.getCache(mContext, mCacheKey, mClazz);
	}
}
